<?php
class ContactsController extends AppController {

	var $name = 'Contacts';
	var $uses = array('Contact');
	
	function index() {
		//$lang=$this->Session->read('lang');
		$lang=0;
		$this->Contact->recursive = 0;
		$conditions=array('Contact.lang_id'=>$lang);
		$this->paginate = array('conditions' =>$conditions,'order'=>'Contact.id  DESC','limit' =>20);
        $Contacts = $this->paginate('Contact');
		$this->set('Contacts',$Contacts);
	}
	function view($id=null) {
		if (!$id) {
			$this->Session->setFlash(__('Không tồn tại', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('views', $this->Contact->findById($id));
	}
		function delete() {
		if($_POST['chkId']){
			$Idnews=$_POST['chkId'];
			foreach($Idnews as $id){
				$this->Contact->delete($id);			
			}
			$this->Session->setFlash(__('Bạn Delete thành công', true));
			$name=$_SERVER['HTTP_REFERER'];
			$this->redirect($name);
		}
	}
}
?>